package org.ghost.wechat.platform.dao;

import org.ghost.wechat.platform.common.http.annotation.HttpClientEx;
import org.ghost.wechat.platform.common.http.annotation.RequestMappingEx;
import org.ghost.wechat.platform.dto.WeChatErrorRspDTO;
import org.ghost.wechat.platform.dto.wechat.menu.*;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 01
 * https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html
 */
@HttpClientEx(hostName = "https://api.weixin.qq.com")
public interface IWeChatMenuDAO {
    /**
     * 创建菜单
     * https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Creating_Custom-Defined_Menu.html
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      菜单对象
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/menu/create", method = HttpMethod.POST)
    WeChatErrorRspDTO createMenu(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatCreateMenuReqDTO reqDTO);

    /**
     * 获取默认菜单和全部个性化菜单信息
     * https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Getting_Custom_Menu_Configurations.html
     *
     * @param accessToken 调用接口凭据
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/menu/get", method = HttpMethod.GET)
    WeChatGetMenuRspDTO getMenu(@RequestParam(value = "access_token") String accessToken);

    /**
     * 使用接口创建自定义菜单后，开发者还可使用接口删除当前使用的自定义菜单。另请注意，在个性化菜单时，调用此接口会删除默认菜单及全部个性化菜单
     * https://developers.weixin.qq.com/doc/offiaccount/Custom_Menus/Deleting_Custom-Defined_Menu.html
     *
     * @param accessToken 调用接口凭据
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/menu/delete", method = HttpMethod.GET)
    WeChatErrorRspDTO deleteMenu(@RequestParam(value = "access_token") String accessToken);

    /**
     * 创建个性化菜单
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      菜单对象
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/menu/addconditional", method = HttpMethod.POST)
    WeChatCreateConditionalMenuRspDTO createConditionalMenu(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatCreateConditionalMenuReqDTO reqDTO);

    /**
     * 删除个性化菜单
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"menuid":"208379533"}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/menu/delconditional", method = HttpMethod.POST)
    WeChatErrorRspDTO deleteConditionalMenu(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatDeleteConditionalMenuReqDTO reqDTO);

    /**
     * 测试个性化菜单匹配结果
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"user_id":"weixin"},user_id可以是粉丝的OpenID，也可以是粉丝的微信号
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/menu/trymatch", method = HttpMethod.POST)
    WeChatTryMatchConditionalMenuRspDTO tryMatchConditionalMenu(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatTryMatchConditionalMenuReqDTO reqDTO);
}
